package cn.piesat.scanning.business.xz.service.clientimpl;

import cn.piesat.scanning.business.xz.service.BuildAlgorithmTaskService;
import cn.piesat.scanning.business.xz.single.AlgorithmTaskPathParam;
import cn.piesat.scanning.business.xz.single.AlgorithmTaskRuleParam;
import cn.piesat.scanning.dto.HtScanningMetadataDTO;
import cn.piesat.scanning.service.HtScanningMetadataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Ming
 * @version 1.0
 * @description: TODO
 * @date 2023/12/18 13:48
 */
@Service
public class BuildFY4A_AGRI_L1_4000MServiceImpl implements BuildAlgorithmTaskService {

    @Autowired
    private HtScanningMetadataService htScanningMetadataService;
    @Override
    public Map<String, Object> initAlgorithmParams(String adsType, String primaryFile, String filePath, AlgorithmTaskRuleParam taskRuleParam, AlgorithmTaskPathParam taskPathParam, Map<String, Integer> indexParams, String fileDate, String scanningPath,HtScanningMetadataDTO htScanningMetadataDTO) {
        Map<String, Object> algorithmParams = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("primaryFile", primaryFile);
        //FY4A_L1级原始数据预处理算法
        HtScanningMetadataDTO metadataDTO = htScanningMetadataService.findOneByDate(fileDate, "L1", "FY4A",
                "GEO", "DISK", "GEO");
        if (null == metadataDTO) {
            algorithmParams.put("parameter01", null);
        } else {
            params.put("geofile", taskPathParam.getParameter02() + metadataDTO.getFilePath());
            params.put("WorkFlow", taskPathParam.getParameter03());
            params.put("SSLRID", taskPathParam.getParameter04());
            params.put("Bands", taskPathParam.getParameter05());
            params.put("Region", taskPathParam.getParameter06());
            params.put("ProjectionIdentify", "GLL");
            params.put("Projection", true);
            params.put("SingleBand", false);
            params.put("Format", "NC");
            params.put("ExportIMG", true);
            params.put("ExportAngles", true);
            params.put("ExportDEM", false);
            params.put("Thumbnail", false);
            algorithmParams.put("parameter00", adsType);
            algorithmParams.put("parameter01", params);
        }
        return algorithmParams;
    }
}
